<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>操作数组元素</title>
</head>
<body>
	<h1>操作数组元素</h1><hr>
	<script type="text/javascript">
		var myArr = new Array("This is the first sentence", "这里是第2句话", "3842", "qwerttuip", "ASDEernnhbbNird");
		document.write("<br>数组的初始值内: ");
		for(var i in myArr) {
			document.write(myArr[i] + " ");
		}
		
		document.write("<br><br>前面3个元素的值: ");
		document.write(myArr.slice(0, 3));
		
		document.write("<br><br>按字母排序: ");
		document.write(myArr.sort());
		
		document.write("<br><br>排序后前面3个元素的值: ");
		document.write(myArr.slice(0, 3));
		
		//splice返回被删除的元素
		document.write("<br><br>删除第3第1个元素: ");
		document.write(myArr.splice(2, 3));
		
		document.write("<br>数组的初始值内: ");
		for(var i in myArr) {
			document.write(myArr[i] + " ");
		}
		
		
		
		
		
	</script>

	
</body>
</html>